package sg.nus.iss.vmcs.guilisteners;

import java.awt.Button;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import sg.nus.iss.vmcs.controllers.MaintenanceController;

/**
 * Action Listener for the Coin Display in the Maintenance Panel<br><br>
 * Modifications:
 * <li>Philip - 28/12/2010 - Removed temporary variables in actionPerformed</li>
 * <br><br>
 * @author Pang Pingli
 * @author Philip Chew
 */
public class CoinDisplayListener implements ActionListener {
	
	/** Maintenance Controller */
	private MaintenanceController mctrl;

	/**
	 * Creates a new instance of the Coin Display Listener
	 * @param mc Reference to maintenance controller
	 */
	public CoinDisplayListener(MaintenanceController mc) {
		mctrl = mc;
	}
	
	/**
	 * Implementation of Action Performed
	 */
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() instanceof Button) {
			mctrl.displayCoin(Integer.parseInt(((Button)e.getSource()).getActionCommand()));
		}
	}
}